/**
 * Created by jiexin on 2017/8/25.
 */

layui.use(['form', 'element', 'layer'], function() {
    var form = layui.form;
    var element = layui.element;
    var $ = layui.jquery;
    var layer = layui.layer; //弹层


    if (err_status === 2){
        layer.msg("用户被禁用")
    }else if(err_status === 3){
        layer.msg("用户密码错误")
    }
    var cookieAccount = $.cookie('userName');
    var cookiePassword = $.cookie('passWord');
    if (cookieAccount && cookieAccount !== '') {
        $("#username").val(cookieAccount);
        $("#password").val(cookiePassword)
    }
    // var switch_status = false;
    // form.on('submit(submitlanding)', function(data) {
    //     var formdata = data.field;
    //     console.log(formdata);
    //     var senddata = {};
    //     senddata["username"] = formdata["username"];
    //     senddata["password"] = formdata["passwd"];
    //     console.log(formdata["username"],"##########");
        // $.ajax({
        //     url: "/login/",
        //     dataType: 'json',
        //     type: 'POST',
        //     data: {"userdata": JSON.stringify(senddata)},
        //     success: function (result) {
        //         if (switch_status){
        //             $.cookie('userName', senddata["username"], { expires: 7 });
        //             $.cookie('passWord', senddata["password"], { expires: 7 });
        //         }
        //         window.location.href="/index";
        //     }
        // });
    // });
    // form.on('switch(keeppwd)', function(data){
    //     // switch_status = data.elem.checked; //开关是否开启，true或者false
    //     // console.log(switch_status)
    //     if (data.elem.checked){
    //         // $.cookie('userName', $("#username").val(cookieAccount), { expires: 1 });
    //         // $.cookie('passWord', $("#password").val(cookiePassword), { expires: 1 });
    //     }else{
    //         $.cookie('userName', '', { expires: -1 });
    //         $.cookie('passWord', '', { expires: -1 });
    //     }
    // })

    // $('.demoTable .layui-btn').on('click', function() {
    //     var type = $(this).data('type');
    //     active[type] ? active[type].call(this) : '';
    // });
});




